package switchviz.graphic;

import org.jdom.Element;

import switchviz.graphic.gauge.IGauge;
import switchviz.graphic.gauge.bargraph.BarGraph;
import switchviz.graphic.gauge.graph2d.Graph2d;
import switchviz.graphic.gauge.tacho.Tacho3dMulti;
import switchviz.graphic.signal.BasicSignalDataModel;
import switchviz.graphic.signal.ComplexSignal;
import switchviz.graphic.signal.IGaugeSignal;
import switchviz.graphic.signal.SimpleSignal;
import switchviz.graphic.signal.TestSignal;

public class GraphicFactory 
{
	private static GraphicFactory _instance = null;
	
	public static GraphicFactory getInstance()
	{
		if(_instance == null)
			_instance = new GraphicFactory();
			
		return _instance;
	}
	
	public IGauge getGauge(String name, Element node)
	{	
		IGauge gauges = null;
		
		if (name.equals("Tacho3d"))
		{
			gauges = new Tacho3dMulti(name, node);
		}
		else if (name.equals("Graph2d"))
		{
			gauges = new Graph2d(name, node);
		}
		else if (name.equals("BarGraph"))
		{
			gauges = new BarGraph(name, node);
		}		
		return gauges;
	}
	
	public IGaugeSignal getSignal(String name, Element node)
	{
		IGaugeSignal signal = null;
		if(name.equals(BasicSignalDataModel.TYPETEST))
		{
			signal = new TestSignal(node);
		}
		else if(name.equals(BasicSignalDataModel.TYPESIMPLE))
		{
			signal = new SimpleSignal(node);
		}
		else if(name.equals(BasicSignalDataModel.TYPECOMPLEX))
		{
			signal = new ComplexSignal(node);
		}
		
		return signal;
	}
}
